<template>
	<view class="content">
		<view class="btn-row">
			<button v-if="!hasLogin" type="primary" class="primary" @tap="bindLogin">登录</button>
			<button v-if="hasLogin" type="default" @tap="bindLogout">退出登录</button>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'

	export default {
		computed: {
			...mapState(['hasLogin', 'forcedLogin','token'])
		},
		methods: {
			...mapMutations(['logout']),
			bindLogin() {
				uni.navigateTo({
					url: '../login/login',
				});
			},
			bindLogout() {
				
				uni.request({
					url:"http://387d4s.natappfree.cc/user/logout/"+this.token,
					method:"PUT",
					success: (res) => {
						this.logout();
						uni.showToast({
							title:res.data.message,
							icon:"none"
						});
					}
				})
			}
		}
	}
</script>

<style>

</style>
